Vuetify is a popular UI framework for Vue apps.
In this article, we’ll look at how to work with the Vuetify framework.
Dividers and Subheaders
We can add dividers to subheaders.
For example, we can write:
<template>
<v-container>
<v-row>
<v-col col="12">
<v-card>
<v-toolbar color="orange lighten-1" dark>
<v-app-bar-nav-icon></v-app-bar-nav-icon>
<v-toolbar-title>Message Board</v-toolbar-title>
<v-spacer></v-spacer>
<v-btn icon>
<v-icon>mdi-magnify</v-icon>
</v-btn>
</v-toolbar>
<v-list two-line>
<template v-for="(item, index) in items">
<v-divider v-if="item.divider" :key="index" inset></v-divider>
<v-list-item v-else :key="item.title" ripple>
<v-list-item-avatar>
<img :src="item.avatar" />
</v-list-item-avatar>
<v-list-item-content>
<v-list-item-title v-html="item.title"></v-list-item-title>
<v-list-item-subtitle v-html="item.subtitle"></v-list-item-subtitle>
</v-list-item-content>
</v-list-item>
</template>
</v-list>
</v-card>
</v-col>
</v-row>
</v-container>
</template>
<script>
export default {
name: "HelloWorld",
data: () => ({
items: [
{ divider: true },
{
avatar: "https://picsum.photos/250/300?image=660",
title: "Meeting",
subtitle: "subtitle",
},
{ divider: true },
{
avatar: "https://picsum.photos/250/300?image=146",
title: "So long",
subtitle: "subtitle",
},
{ divider: true },
{
avatar: "https://picsum.photos/250/300?image=1008",
title: "Breakfast",
subtitle: "subtitle",
},
],
}),
};
</script>
We added the v-divider
dynamically in with the v-divider
and v-if
directive.
We used it to divide the v-list-item
.
v-list-item
has the items we’re dividing.
Dividers in Portrait View
Also, we can add dividers in portrait view.
For example, we can write:
<template>
<v-container>
<v-row>
<v-col col="12">
<v-card>
<v-card-title class="cyan darken-1">
<span class="headline white--text">Sarah Smith</span>
<v-spacer></v-spacer>
<v-btn dark icon>
<v-icon>mdi-chevron-left</v-icon>
</v-btn>
<v-btn dark icon>
<v-icon>mdi-pencil</v-icon>
</v-btn>
<v-btn dark icon>
<v-icon>mdi-dots-vertical</v-icon>
</v-btn>
</v-card-title>
<v-list>
<v-list-item>
<v-list-item-action>
<v-icon>mdi-phone</v-icon>
</v-list-item-action>
<v-list-item-content>
<v-list-item-title>123-456-7890</v-list-item-title>
</v-list-item-content>
<v-list-item-action>
<v-icon>mdi-message-text</v-icon>
</v-list-item-action>
</v-list-item>
<v-divider inset></v-divider>
<v-list-item>
<v-list-item-action>
<v-icon>mdi-email</v-icon>
</v-list-item-action>
<v-list-item-content>
<v-list-item-title>sarah@example.com</v-list-item-title>
</v-list-item-content>
</v-list-item>
<v-divider inset></v-divider>
<v-list-item>
<v-list-item-action>
<v-icon>mdi-map-marker</v-icon>
</v-list-item-action>
<v-list-item-content>
<v-list-item-title>New York</v-list-item-title>
</v-list-item-content>
</v-list-item>
</v-list>
<v-img src="http://placekitten.com/600/200" height="200px"></v-img>
</v-card>
</v-col>
</v-row>
</v-container>
</template>
<script>
export default {
name: "HelloWorld",
data: () => ({}),
};
</script>
We have the v-divider
between the v-list-item
s with the inset
props.
This will make the divider shown below the text on the right side.
The icons won’t have the divider below them.
Conclusion
We can add dividers to separate list items.